<%@ page language ="java" import="java.sql.*" %>
<html>
<body bgcolor="white">
<form name="f1" method="post">
<title>Prihlaseni do databaze</title>
<h1>Prihlaseni do databaze</h1>
<table>
<tr>
<td>User Name</td><td><input type="text" name="t1" ></td>
</tr>
<td>Password</td>
<td><input type=""password"" name="t2"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="b1" value="LogIn"></td>
</tr>
</table>
<%
String user=request.getParameter("t1");			// Nacteni uzivatelskeho jmena	
String pass=request.getParameter("t2");			// Nacteni hesla
int i=0;
     try{
    
     Class.forName("com.mysql.jdbc.Driver");
    // Connection con=DriverManager.getConnection("jdbc:mysql://mysql.wz.cz:3306/gsmmodulesinm","gsmmodulesinm","jp9taa");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/skola","A","aaa");
    Statement st=con.createStatement();
    ResultSet rs=st.executeQuery("select uzivatel,heslo from pristup");
   							// Nacteni uzivatelskeho jmena a hesla z databaze
     while(rs.next())
         {
         String username=rs.getString(1);		// Vyserapovani uzivatelskeho jmena
         String password=rs.getString(2);		// Vyseparovani hesla
         if(user.equals(username) && pass.equals(password))		// Porovnani
             {			// Spusteni servletu na zobrazeni databaze
             %>
             <jsp:forward page="test1" />			
         <%}
         else
         out.println("Login Failed,Please try Againe");
         
        	 
        	
        
     }
}catch(SQLException e1)
{
	out.println("<p>Pri pokusu o pripojeni do databaze doslo k naseldujici chybe/n"+e1.getMessage()+"<p>");
	}
catch(Exception e) {
    	// 
     }

%>

</form>
</body>
</html>

